package jp.dodododo.aop.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import jp.dodododo.aop.Aspects;
import jp.dodododo.aop.Aspect;
import jp.dodododo.aop.annotation.Enhance;

@Enhance(false)
public class AspectsImpl implements Aspects {

	private List<Aspect> aspectDefs = new ArrayList<Aspect>();

	public List<Aspect> getAspectList() {
		return aspectDefs;
	}

	public void addAspectDef(Aspect aspectDef) {
		aspectDefs.add(aspectDef);
	}

	public void appendFirst(Aspects aspects) {
		List<Aspect> aspectList = aspects.getAspectList();
		for (int i = 0; i < aspectList.size(); i++) {
			this.aspectDefs.add(i, aspectList.get(0));
		}
	}

	public void appendLast(Aspects aspects) {
		List<Aspect> aspectList = aspects.getAspectList();
		for (Iterator<Aspect> iter = aspectList.iterator(); iter.hasNext();) {
			this.aspectDefs.add(iter.next());

		}
	}

	public void remove(Aspects aspects) {
		List<Aspect> aspectList = aspects.getAspectList();
		for (Iterator<Aspect> iter = aspectList.iterator(); iter.hasNext();) {
			this.aspectDefs.remove(iter.next());
		}
	}

}
